import openpyxl

# 打开Excel文件
wb = openpyxl.load_workbook('../data/幻兽帕鲁配种表.xlsx')

# 选择工作表
sheet = wb['全配种表']

# 获取表头数据
headers_row = sheet[1]
headers_column = [sheet.cell(row=i, column=1).value for i in range(2, sheet.max_row + 1)]

# 输入任意一个非表头数据
target_value = '苍炎狼'

# 查找对应的表头值
matched_headers = []
for i in range(2, sheet.max_row + 1):
    for j in range(2, sheet.max_column + 1):
        if sheet.cell(row=i, column=j).value.find(target_value) != -1:
            matched_headers.append((headers_row[j-1].value, headers_column[i - 2]))

# 输出对应的表头值
if matched_headers:
    print("对应的表头值为：")
    for header in matched_headers:
        print(header[0], header[1])
else:
    print("未找到对应的表头值")